Conversation
src/engine/lua.cc
Outdated
|
|
||
| lua_newtable(L); | ||
| for (auto i : l) { | ||
| for (auto* i : l) { |
There was a problem hiding this comment.
| for (auto* i : l) { | |
| for (const auto* i : l) { |
The original code was written about 8 years ago, the author is no longer involved in development.
If I had to guess why they used value copy mechanism, I would say they wanted to avoid any chance to modify the value on Lua stack (except for intentional change with setvar()).
If we want to keep this restriction, please consider to use const modifier here.
src/rules_exceptions.cc
Outdated
| } | ||
|
|
||
| for (auto z : m_ranges) { | ||
| for (auto& z : m_ranges) { |
There was a problem hiding this comment.
| for (auto& z : m_ranges) { | |
| for (const auto& z : m_ranges) { |
Please see cppcheck's warning:
warning: src/rules_exceptions.cc,198,style,constVariableReference,Variable 'z' can be declared as reference to const
src/rules_exceptions.cc
Outdated
| } | ||
| } | ||
| for (auto b : from->m_ranges) { | ||
| for (auto& b : from->m_ranges) { |
There was a problem hiding this comment.
| for (auto& b : from->m_ranges) { | |
| for (const auto& b : from->m_ranges) { |
Please see cppcheck's warning:
warning: src/rules_exceptions.cc,215,style,constVariableReference,Variable 'b' can be declared as reference to const
src/transaction.cc
Outdated
| strlen("messages")); | ||
| yajl_gen_array_open(g); | ||
| for (auto a : m_rulesMessages) { | ||
| for (auto& a : m_rulesMessages) { |
There was a problem hiding this comment.
| for (auto& a : m_rulesMessages) { | |
| for (const auto& a : m_rulesMessages) { |
Probably here you could use const too.
src/transaction.cc
Outdated
| strlen("tags")); | ||
| yajl_gen_array_open(g); | ||
| for (auto b : a.m_tags) { | ||
| for (auto& b : a.m_tags) { |
There was a problem hiding this comment.
| for (auto& b : a.m_tags) { | |
| for (const auto& b : a.m_tags) { |
Probably here you could use const too.
|
I was not sure if there was any restriction not to use const, thats why i asked. I could extend the PR with more positions for "const auto&" if you like. |
Sure, go! If the tests will be passed, I'll be happy :). Btw you could review the tests too, may be you will find some lack there too (for eg. you're checking the code...) |
with changes from e9bf9ad nothing is modified anymore
|
|
Hi @edding3000, sorry for the long delay, it seems like this PR is ready to merge. Just one question: could you merge the current v3/master into this one? |
|
also please take a look at the few request changes. |



what
Range based for loops with references are already used in this project, but in a few places not.
I am not sure why. I changed this code locations and executed unit tests.
Also use '*' for pointers when using auto keyword, makes it more readable.
why
Improve performance a little bit.
questions
"const auto&" could also be used in many places. Is there a reason why it is not used?